package com.fang.mmy.items.filter;

import com.fang.mmy.items.constants.Constants;
import com.fang.mmy.items.entity.ItemRuleDetail;

/**
 * @ClassName BaseLogic
 * @Author kebukeyi
 * @Date 2022/8/9 18:52
 * @Description
 * @Version 1.0.0
 */
public abstract class BaseLogic {


    protected boolean decisionLogic(String matterValue, ItemRuleDetail detail) {
        switch (detail.getItemRulePk()) {
            case Constants.RuleLimitType.EQUAL:
                return matterValue.equals(detail.getItemRuleValue());
            case Constants.RuleLimitType.GT:
                return Double.parseDouble(matterValue) > Double.parseDouble(detail.getItemRuleValue());
            case Constants.RuleLimitType.LT:
                return Double.parseDouble(matterValue) < Double.parseDouble(detail.getItemRuleValue());
            case Constants.RuleLimitType.GE:
                return Double.parseDouble(matterValue) >= Double.parseDouble(detail.getItemRuleValue());
            case Constants.RuleLimitType.LE:
                return Double.parseDouble(matterValue) <= Double.parseDouble(detail.getItemRuleValue());
            default:
                return false;
        }
    }
}
